﻿#nullable disable
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XiaoYuJi.Entity.SysEntitys;
using XiaoYuJi.Repository.BusRepository;

namespace XiaoYuJi.Service.SysServices;
public class UserService:BaseService<SysUser>,IUserService
{

    public UserService(IUserRepository userRepository)
        :base(userRepository)
    {
        
    }

    public async Task<SysUser> VerifyUser(string userName, string password)
    {
        if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
        {
            throw new ArgumentNullException("请输入用户名或密码！");
        }

        //查询用户
        SysUser user = await _repository.Query(e => e.UserName.Equals(userName)
            && e.UserPwd.Equals(password) && e.IsDelete == false)
            .Include(e => e.SysRole)
            .SingleOrDefaultAsync();

        return user;
    }
}
